#!/usr/bin/python
# -*- coding: UTF-8 -*-

#开关苹果app

from mysql import MysqlManager

db = MysqlManager()

def main():
	results = db.select("select config_value from config where id=49 and config_key='apple_version'")
	versionStr=results[0][0]
	versions = versionStr.split(',')
	if len(versions)>1:	#跳过第一个是因为第一个用来审核的，如果没有审核的，随便插入一个
		#备份当前配置
		f=open('doorKey','w')
		f.write(versionStr)
		f.close()

		#打开开关
		db.update("update config set config_value='%s' where id=49 and config_key='apple_version' "%versions[0])

		#切换线上包
		db.update("update download_url set status=1 where id=6")	#线上包
		db.update("update download_url set status=0 where id=3")	#企业包

		#开强更
		db.update("update config set config_value=1 where id=54 and config_key='update_app_store' ")
		# print sql
	
main()
db.close()
